package main

import (
	"context"
	"github.com/grpc-ecosystem/grpc-gateway/runtime"
	"google.golang.org/grpc"
	"grpc/helper"
	"grpc/services"
	"log"
	"net/http"
)

func main(){
	gwmux := runtime.NewServeMux()
	gRpcEndPoint := "localhost:8088"
	opt := []grpc.DialOption{grpc.WithTransportCredentials(helper.GetClientCreds())}
	err := services.RegisterProdServiceHandlerFromEndpoint(context.Background(),gwmux,gRpcEndPoint,opt)
	if err != nil {
		log.Fatal(err)
	}
	err = services.RegisterOrderServiceHandlerFromEndpoint(context.Background(),gwmux,gRpcEndPoint,opt)
	if err != nil {
		log.Fatal(err)
	}
	httpServer := &http.Server{
		Addr: ":8080",
		Handler: gwmux,
	}
	httpServer.ListenAndServe()
}
